package com.aptemo.webetek.shared;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;

import com.aptemo.webetek.client.commands.Response;
import com.aptemo.webetek.client.enums.EnumEventStatus;
import com.aptemo.webetek.client.enums.EnumEventType;
import com.aptemo.webetek.client.enums.EnumPickStatus;

public class EventBean implements Response, Comparable<EventBean>, Serializable
{

	/**
	 * 
	 */
	private static final long	serialVersionUID	= 4970610465985344044L;

	private String				id;

	private String				teamId;

	private String				title;

	private String				description;

	private EnumEventType		eventType;

	private Date				date;

	private ArrayList<PickBean>	picks				= new ArrayList<PickBean>();

	private EnumEventStatus		status;

	private ArrayList<String>	labels;

	private String				resultDescription;

	protected EventBean()
	{
	}

	public EventBean(Date date, String atitle, String adescription)
	{
		title = atitle;
		description = adescription;
		setDate(date);
	}

	public void setKey(String key)
	{
		this.id = key;
	}

	public String getKey()
	{
		return this.id;
	}

	public String getTitle()
	{
		return title;
	}

	public void setTitle(String atitle)
	{
		title = atitle;
	}

	public String getDescription()
	{
		return description;
	}

	public void setDescription(String adesc)
	{
		description = adesc;
	}

	public void setBetType(EnumEventType type)
	{
		this.eventType = type;
	}

	public EnumEventType getEventType()
	{
		return eventType;
	}

	public void setDate(Date date)
	{
		this.date = date;
	}

	public Date getDate()
	{
		return date;
	}

	// public String getDate()
	// {
	// if (date != null)
	// return date.toString();
	// return "";
	// }

	public void setPicks(ArrayList<PickBean> picks)
	{
		this.picks = picks;
	}

	public ArrayList<PickBean> getPicks()
	{
		return picks;
	}

	public EnumEventStatus getStatus()
	{
		return this.status;
	}

	public void setStatus(EnumEventStatus status)
	{
		this.status = status;
	}

	public void setLabels(ArrayList<String> lkeys)
	{
		labels = lkeys;
	}

	public ArrayList<String> getLabels()
	{
		return labels;
	}

	@Override
	public int compareTo(EventBean bet)
	{
		return this.getDate().compareTo(bet.getDate());
	}

	public String getResultDescription()
	{
		return resultDescription;
	}

	public void setResultDescription(String resultDescription)
	{
		this.resultDescription = resultDescription;
	}

	public PickBean getWinPick()
	{
		for (PickBean pick : picks)
		{
			if (pick.getStatus() == EnumPickStatus.WON)
			{
				return pick;
			}
		}
		return null;
	}

	public String getTeamId()
	{
		return teamId;
	}

	public void setTeamId(String teamId)
	{
		this.teamId = teamId;
	}
}
